package com.jiepos.mpos.biz.appInfM.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;

import com.jiepos.mpos.biz.appInfM.service.ShareService;
import com.jiepos.mpos.common.entity.App_Ins_InfEntity;
import com.jiepos.mpos.common.entity.App_Share_InfEntity;
import com.jiepos.mpos.core.controller.BaseController;
import com.jiepos.mpos.core.entity.Pagination;

/**
 *
 *
 * <p>标题: —— 系统参数控制器</p>
 * <p>模块: 通用平台</p>
 * <p>版权: Copyright (c) 2017 江苏杰博实信息技术有限公司
 * @author 余翼膑
 * @version 1.0
 * @since 2017年01月30日
 * @history（历次修订内容、修订人、修订时间等）
 */


@Controller
@RequestMapping("share")
public class ShareContorller extends BaseController {
    @Autowired
    private ShareService shareService;

    /**
     * 进入页面
     * @param request
     * @param response
     * @param pagination
     * @return
     */
    @RequestMapping("/getShareList.do")
    public ModelAndView getShareList(HttpServletRequest request, HttpServletResponse response, Pagination pagination){

        ModelAndView model = new ModelAndView("/module/appInfM/share/share_list");
        return super.getDetail(request, response, model);
    }
    /**
     * 查询列表信息json数据
     * @param pagination
     * @param appShareInfEntity
     * @return
     */
    @RequestMapping("/shareListJson.do")
    public @ResponseBody
    Map getShareListJson(HttpServletRequest request, Pagination pagination, App_Share_InfEntity appShareInfEntity, App_Ins_InfEntity appInsInfEntity){
        return shareService.getShareList(request,pagination, appShareInfEntity,appInsInfEntity);
    }
    /**
     * 进入详细页面
     * @param request
     * @param response
     * @param pagination
     * @param share_uuid
     * @return
     */
    @RequestMapping("/getShareDetail.do")
    public ModelAndView getShareDetail(HttpServletRequest request, HttpServletResponse response,
                                        Pagination pagination,String share_uuid) {
        ModelAndView model = new ModelAndView("/module/appInfM/share/share_detail");
        // 菜单编码
        Map shareEntity = shareService.getShareById(share_uuid);
        model.addObject("shareEntity", shareEntity);
        return super.getDetail(request, response, model);
    }
    /**
     * 保存信息
     * @param request
     * @param response
     * @param appShareInfEntity
     * @return
     */
    @RequestMapping("/saveShareDetail.do")
    public ModelAndView saveNoticeDetail(HttpServletRequest request, HttpServletResponse response, App_Share_InfEntity appShareInfEntity,String publish_date) {
        shareService.saveShare(request,appShareInfEntity,publish_date, super.getLoginUser(request, response));
        Map map=super.getLoginUser(request, response);
        return new ModelAndView(new RedirectView("getShareList.do"), map);
    }
    /**
     * 更新发布状态
     * @param request
     * @param response
     * @param share_uuids
     * @return
     */
    @RequestMapping("/updShareDetail.do")
    @ResponseBody
    public void updNoticeDetail(HttpServletRequest request, HttpServletResponse response, String share_uuids, String publish_st ) {
        shareService.updShareDetail(share_uuids,publish_st, super.getLoginUser(request, response));
    }
}
